package com.scalpel.controller;

import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.scalpel.Interceptor.ProductInterceptor;
import com.scalpel.model.Product;

import java.util.List;

/**
 * Created by scalpel on 2017/1/20.
 */
public class ProductController extends Controller {

    @Before(ProductInterceptor.class)
    public void index()
    {
        List<Product> data = Product.dao.find("select * from product");
        setAttr("data",data);
        render("/index.html");
    }

    public void add()
    {

        render("/add.html");
    }

    public void addSave()
    {
        Product product = getModel(Product.class);
        product.save();
        redirect("/product/index");
    }
}
